# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>

_hkgname=old-time
pkgname=haskell-old-time
pkgver=1.1.0.3
pkgrel=30
pkgdesc="This package provides the ability to adapt to locale conventions such as date and time formats."
url="https://hackage.haskell.org/package/${_hkgname}"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-old-locale')
makedepends=('ghc')
source=(https://hackage.haskell.org/package/${_hkgname}-${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('a701c62266f9f3c6dc60eba970b6c25a61bf82b6b8bb6b0073e0e44908598926fe7813a7ae1b1f9da98e4861a8f0565d0bd025cb97307b71c08cb9b0b2e321bb')

prepare() {
    sed -i 's/base       >= 4.7 && < 4.9/base       >= 4.7/' ${_hkgname}-${pkgver}/${_hkgname}.cabal
}

build() {
    cd $_hkgname-$pkgver

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-debug
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
